package com.newbye.uis
{
	import flash.events.MouseEvent;
	
	import mx.controls.treeClasses.TreeItemRenderer;
	import mx.core.DragSource;
	import mx.core.IFactory;
	import mx.managers.DragManager;
	
	public class ComponentListItemRenderer extends TreeItemRenderer implements IFactory
	{
		public function ComponentListItemRenderer()
		{
			super();
			this.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
			this.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
			this.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
		}
		private function onMouseDown(e:MouseEvent):void
		{
			var ds:DragSource = new DragSource();
			ds.addData(this.data, "data");
			DragManager.doDrag(this, ds, e, this);
		}
		
		private function onMouseUp(e:MouseEvent):void
		{
			//this.stopDrag();
		}
		
		private function onMouseOut(e:MouseEvent):void
		{
			//this.stopDrag();
		}
		
		public function newInstance():*
		{
			return new ComponentListItemRenderer();
		}
	}
}